import com.dbpms.config.SpringConfig;
import com.dbpms.mapper.MenuPowerMapper;
import com.dbpms.pojo.Noticeinfo;
import com.dbpms.pojo.TestClass;
import com.dbpms.pojo.User;
import com.dbpms.pojo.menuPower.menupowerinfo;
import com.dbpms.service.INoticeService;
import com.dbpms.service.IUserService;
import com.dbpms.service.ItestService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
public class test {

    @Autowired
    private IUserService userService;

    @Autowired
    private ItestService itestService;
    @Test
    public void test(){
        User user = userService.login("admin","123456");
        System.out.println(user.getUserAccount());
    }
    @Test
    public void test1(){
        TestClass test = new TestClass();
        test.setId(1);
        test.setName("admin");
        itestService.save(test);
    }
    @Test
    public void test2(){
        TestClass testClass = itestService.login("admin");
        System.out.println(testClass.getId());
    }
    @Resource
    private MenuPowerMapper menuPowerMapper;
    @Test
    public void test3(){
        List<menupowerinfo> info;
//        LambdaQueryWrapper<menupowerinfo> wrapper = new LambdaQueryWrapper<menupowerinfo>()
//                .eq(menupowerinfo::getMenuPowerStuRole,1)
//                .orderByDesc(menupowerinfo::getMenuPowerId);
//        info = menuPowerMapper.selectList(wrapper);
        info = userService.getMenuPowerInfo(1);
        System.out.println(info);
    }

    @Autowired
    private INoticeService iNoticeService;
    @Test
    public void test4(){

//        System.out.println(iNoticeService.titleQueryNoticeInfo("标题"));;
        //删除
//        boolean pd = iNoticeService.deleteNoticeInfo(12);
//        System.out.println(pd);
        //新增
        Noticeinfo noticeinfo = new Noticeinfo();
        noticeinfo.setNoticeTitle("title");
        noticeinfo.setNoticeContent("contact");
        noticeinfo.setNoticeDetail("detail");
        noticeinfo.setNoticePublisher("user.getUserDetail()");
        boolean pd = iNoticeService.save(noticeinfo);
        System.out.println(pd);
    }
    @Test
    public void test45(){
        String name = "1a33ea35c4f52fed7d161db8caa975d.jpg";
        System.out.println(name.substring(name.indexOf(".") + 1));
    }
    }
